<?php include_once "head.php"?>
<!--<style>-->
<!--    table{-->
<!---->
<!--        table-layout:fixed;/* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */-->
<!--    }-->
<!--    td{-->
<!--        width:100%;-->
<!--        word-break:keep-all;/* 不换行 */-->
<!--        white-space:nowrap;/* 不换行 */-->
<!--        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */-->
<!--        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/-->
<!--    }-->
<!--</style>-->
<table class="layui-table">
    <colgroup>
        <col width="6%">
        <col width="8%">
        <col width="20%">
        <col width="8%">
        <col width="8%">
        <col width="12%">
        <col width="8%">
        <col width="22%">
    </colgroup>
    <thead>
    <tr>
        <th>视频ID</th>
<!--        <th>ID</th>-->
        <th>缩略图</th>
        <th>视频标题</th>
        <th>话题</th>
        <th>用户</th>
        <th>用户上传时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php if(!empty($data['row'])){
        foreach($data['row'] as $k=>$v){
    ?>
    <tr>
            <input type="hidden" value="<?=$v['id']?>" class="video_uuid<?=$k+1?>">
<!--            <td>--><?//=$v['video_uuid']?><!--</td>-->
            <td><?=$v['id']?></td>
            <td>
                <img src="<?=$v['pic']?>" style="width:90px;height: 65px;" class="video<?=$k+1;?>">
                <input type="hidden" value="<?=$v['video_url']?>" class="content<?=$k+1;?>">
            </td>
            <td><?=$v['video_desc']?></td>
            <td><?=$v['join_type_sub_name']?></td>
            <td><?=$v['nick_name']?></td>
            <td><?=$v['add_time']?></td>
            <?php if($v['mix_status']==0){ ?>
                <td>合成中</td>
            <?php }else if($v['mix_status']==1){ ?>
                <td>合成成功</td>
            <?php }else if($v['mix_status']==2){ ?>
                <td>合成失败</td>
            <?php } ?>

            <td>
                <a href="<?=base_url("user_material/material/edit?video_uuid={$v['id']}")?>" class="layui-btn layui-btn-xs" style="margin-left:5px;margin-bottom:8px;">编辑</a>
                <button class="layui-btn layui-btn-xs layui-btn-normal join<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">通过</button>
                <button class="layui-btn layui-btn-xs layui-btn-warm drop<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">弃用</button>
                <button class="layui-btn layui-btn-xs layui-btn-danger del<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">删除</button>
            </td>
    </tr>
    <?php }}else{ ?>
        <tr>
            <td colspan="7" rowspan="3" style="color: #00CC00;font-size: 25px;height:100px;text-align: center;">暂无数据</td>
        </tr>
    <?php } ?>
    </tbody>
</table>
<div id="demo7"></div>
<script src="<?=SITE_BASE_URL?>/assets/plugins/dyj/layui_url.js"></script>
<script>
    var arr=[];
    for(var i=1;i<51;i++){
        arr.push(i)
    }
    $.each(arr,function(i,n){
        var id=$(".video_uuid"+n).val()
        //通过
        $(".join"+n).click(function(){
            var html="";
            html+="5分很精彩，4分精彩，3分很好，2分不错，1分一般";
            html+="<br>";
            html+="<br>";
            html+="<div class=\"layui-form-item\">";
            html+="<label class=\"layui-form-label\">用户得分</label>";
            html+="<div class=\"layui-input-block\">";
            html+="<input type=\"text\" name=\"user_score\" value=\"\" placeholder=\"请输入用户得分\"class=\"layui-input user_score\">";
            html+="</div>";
            html+="</div>";
            layer.open({
                title:"用户得分"
                ,content: html
                ,btn: ['确认', '取消']
                ,yes: function(index, layero){
                    //按钮【按钮一】的回调
                    var user_score=$(".user_score").val();
                    $.ajax({
                        type: "post",
                        data: {id:id,user_score:user_score},
                        dataType: "json",
                        url: "<?=base_url("user_material/material/join")?>",
                        success: function (res) {
                            if(res.code==0){
                                layer.msg(res.msg, {time:1000},function(){
                                    window.location.reload()
                                });
                            }else{
                                layer.msg(res.msg, {time: 2000});
                            }
                        }
                    })

                }
                ,btn2: function(index, layero){
                    //按钮【按钮二】的回调
                }
                ,cancel: function(){
                    //右上角关闭回调
                }
            });
        })

        //不通过
        $(".drop"+n).click(function(){
            $.ajax({
                type: "post",
                data: {id:id},
                dataType: "json",
                url: "<?=base_url("user_material/material/drop")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.reload()
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })

        //删除
        $(".del"+n).click(function(){
            $.ajax({
                type: "post",
                data: {id:id},
                dataType: "json",
                url: "<?=base_url("user_material/material/del")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.reload()
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })

        //移入缩略图显示和隐藏小手
        $('.video'+n).mouseover(function(){
            $(this).css("cursor","pointer")
        }).mouseout(function(){
            $(this).css("cursor","")
        })
        //视频放大
        $('.video'+n).click(function(){
            var content=$('.content'+n).val();
            var html="";
            html+="<video src='"+content+"' style=\"width:560px;height:400px;\" controls='controls' autoplay></video>"
            layer.open({
                title:'视频播放'
                ,content: html
                ,area:['600px','540px']
                ,btn: ['关闭']
                ,yes: function(index, layero){
//按钮【按钮一】的回调
                    layer.close(index)
                }
                ,cancel: function(){
//右上角关闭回调

//return false 开启该代码可禁止点击该按钮关闭
                }
            });
        })
    })
    $(function(){
        //关键字和日期搜索
        $('.search').click(function(){
            var time=$('.time').val()
            var html="?time="+time;
            var a="<?=base_url("user_material/material/index")?>";
            var view=a+html;
            window.location.href=view
        })
        //监听下拉框变化
        layui.use('form', function(){
            var form = layui.form;
            //监听分类
            form.on('select(join_type)', function(data){
                var join_types=data.value; //得到被选中的值
                window.location.href="<?=base_url("user_material/material/index?join_type=")?>"+join_types;
            });
            //监听话题
            form.on('select(join_type_sub)', function(data){
                var join_type=data.value; //得到被选中的值
                window.location.href="<?=base_url("user_material/material/index?join_type_sub=")?>"+join_type;
            });
        });
        //分页
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            var param = GetRequest();
            //总页数大于页码总数
            laypage.render({
                elem: 'demo7'
                ,count:<?=$data['total']?>//数据总数
                ,curr: <?=$page?>
                ,limit:<?=$limit?>
                ,layout:  ['count', 'prev', 'page', 'next','limit', 'refresh', 'skip']
                ,jump: function(obj,first){
                    //首次不执行
                    if(!first){
                        var url = window.location.href;
                        url = url.substring(0, url.lastIndexOf('?'));

                        param['page'] = obj.curr;
                        param['limit'] = obj.limit;
                        window.location.href = createURL(url,param);
                    }
                }
            });
        });
    })
</script>
